<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Film discuss</title>
	<LINK href="<?php echo base_url();?>css/style.css" type="text/css" rel=stylesheet>
	<LINK href="<?php echo base_url(); ?>css/form_validator/validationEngine.jquery.css" type="text/css" rel=stylesheet>
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery-1.7.1.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery.form_validator.languages/jquery.validationEngine-ru.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery.tablesorter.js"></script>
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery.tablesorter.pager.js"></script>
</head>
<script>
	$(document).ready(function(){
		    $("table") 
    		.tablesorter({widthFixed: true, sortList: [[5,1]]}) 
    		.tablesorterPager({container: $("#pager")}); 
	});
</script>
<body>
	<div id="container">
		<div id="top">
			<a class="navigation" href="/">Главная </a> | <a class="navigation" href="/films_contr/film_add"> Добавить фильм</a>
			
			<?php
				if (isset($is_auth) && ($is_auth == 1)) {
					echo "<b class='auth1'>$email</b><a class='auth' href='/main_contr/logoff'>Выйти</a>";
				}
				else {
					echo "<a class='auth' href='/main_contr/login'>Войти</a>";
				}
			?>
			<p id="error">
			<?php
			if (isset($text)) {
				echo "Внимание!".br();
				echo $text;
			}
			?>
			</p>
			<h1>Главная</h1>
		</div>
		<div id="body">
			<table border="1" class="tablesorter" cellspacing="1">
				<caption>Фильмы</caption>
				<thead>
					<tr>
						<th>Название</th>
						<th>Год выхода</th>
						<th>Жанр</th>
						<th>Рейтинг</th>
						<th>Добавлено</th>
						<th>Последний</th>
						<th>Переход</th>
					</tr>
				</thead>
				<tbody>
					<?php
						$str = '';
						$i = 0;
						foreach ($list as $tmp) {
							foreach ($tmp as $key => $value) {
								switch ($key){
									case 'idfilms':
										$str .= "<td><a href=/films_contr/show_film_info/$value>Подробнее</a></td>";
										$i++;
									break;
									default:
										$str .= "<td>$value</td>";
										$i++;
									break;									
								}
								if ($i == 7) {
									echo "<tr>$str</tr>";
									$i = 0;
									$str = '';
								}
							}
						}
					?>
				</tbody>
			</table>
			<br />
			<div id="pager" class="pager"> 
				<form> 
					<img src="<?php echo base_url();?>images/icons/first.png" class="first"/> 
					<img src="<?php echo base_url();?>images/icons/prev.png" class="prev"/> 
					<input type="text" class="pagedisplay"/> 
					<img src="<?php echo base_url();?>images/icons/next.png" class="next"/> 
					<img src="<?php echo base_url();?>images/icons/last.png" class="last"/> 
					<select class="pagesize"> 
						<option selected="selected"  value="3">3</option> 
						<option value="5">5</option> 
						<option value="10">10</option> 
						<option  value="20">20</option> 
					</select> 
				</form> 
			</div> 
			<br />
			<table border="1" cellspacing="1">
				<caption>Статистика</caption>
				<?php
				foreach ($stat as $key => $value) {
					switch ($key) {
						case 'countfilms':
							echo "<tr><td>Всего фильмов</td><td width='30' align='center'>$value</td></tr>";
						break;
						case 'countfilmstoday':
							echo "<tr><td>Сегодня фильмов</td><td align='center'>$value</td></tr>";
						break;
						case 'countcomments':
							echo "<tr><td>Всего комментариев</td><td align='center'>$value</td></tr>";
						break;
						case 'countcommentstoday':
							echo "<tr><td>Сегодня комментариев</td><td align='center'>$value</td></tr>";
						break;
					}
				}
				?>
			</table>
			
		</div>
		<!--<p id="notice"></p>-->
		<p id="footer">Разработал Утехин Е.А. 2012</p>
	</div>

</body>
</html>